local skel = fk.CreateSkill {
  name = "lb_zero__fuqu",
  tags = { Skill.Limited },
}

local DIY = require "packages.diy_utility.diy_utility"

Fk:loadTranslationTable {
  ["lb_zero__fuqu"] = "弗屈",
  [":lb_zero__fuqu"] = "<b>限定技</b>，当你进入濒死状态时，你可以回复体力至1，重置<a href=':lb_zero__quanyi'><font color='red'>〖拳意〗</font></a>并获得本回合进入弃牌堆中所有的【杀】。 ",

  ["#lb_zero__fuqu"] = "弗屈：你可以回复体力至1，重置〖拳意〗并获得本回合进入弃牌堆中所有的【杀】",

  ["$lb_zero__fuqu1"] = "以此，为誓！",
  ["$lb_zero__fuqu2"] = "以一敌百！",
}

skel:addEffect(fk.EnterDying, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and player:usedSkillTimes(skel.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askToSkillInvoke(player, { skill_name = skel.name, prompt = "#lb_zero__fuqu" })
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:recover {
      who = player,
      num = 1 - player.hp,
      skillName = skel.name,
      recoverBy = player,
    }
    player:setSkillUseHistory("lb_zero__quanyi")
    local cards = table.filter(DIY.getCenterCards(room), function(id)
      return Fk:getCardById(id).trueName == "slash"
    end)
    if player:isAlive() and #cards > 0 then
      room:obtainCard(player, cards, true, fk.ReasonJustMove, player, skel.name)
    end
  end,
})

skel:addAcquireEffect(function(self, player, is_start)
  player.room:addSkill("#CenterArea")
end)

return skel